
package com.qf.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.qf.dao.ProductDao;
import com.qf.model.Product;
import com.qf.model.Pagebean;
import com.qf.utils.C3P0Util;

public class ProductDaoImpl implements ProductDao{

	@Override
	public List<Product> findother(String sql, Object... params) {
		QueryRunner qr = new QueryRunner(C3P0Util.getDatasource());
		List<Product> list=new ArrayList<>();
		
		//TODO
		try {
			 list = qr.query(sql, new BeanListHandler<>(Product.class),params);
		} catch (SQLException e) {
			
			//TODO
			e.printStackTrace();
				
		}
		return list;
	}

	@Override
	public Product findByPid(String pid) {
		QueryRunner qr = new QueryRunner(C3P0Util.getDatasource());
		Product p=null;
		try {
			p = qr.query("select * from product where pid=?", new BeanHandler<>(Product.class),pid);
		} catch (SQLException e) {
			
			//TODO
			e.printStackTrace();
				
		}
		//TODO
		return p;
			
	}

}

	